package izzat.fit.fit_mine.controller;


import izzat.fit.fit_mine.entity.Record;
import izzat.fit.fit_mine.entity.RequestEntity;
import izzat.fit.fit_mine.entity.ResponseEntity;
import izzat.fit.fit_mine.remote.DBRemote;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @ClassName: ActionController
 * @Description:
 * @Author: Izzat
 * @Date: 2019-12-31 19:01
 * @Version: v1.0
 */
@RestController
public class MineController {

    @Autowired
    DBRemote dbRemote;

    @RequestMapping("test")
    /**
     * @Description: 测试是否正常启动
     * @Param: []
     * @return: java.lang.String
     * @Author: Izzat
     * @Date: 2019/12/31  19:11
     */
    public String test() {
        return "MineController";
    }

    @RequestMapping("hello")
    /**
     * @Description: 测试是否成功调用 db-service 服务
     * @Param: []
     * @return: java.lang.String
     * @Author: Izzat
     * @Date: 2019/12/31  19:12
     */
    public String hello() {
        return dbRemote.hello();
    }

    @RequestMapping("allAction")
    /**
     * @Description: 获取所有动作
     * @Param: []
     * @return: java.lang.String
     * @Author: Izzat
     * @Date: 2019/12/31  19:23
     */
    public ResponseEntity allAction() {
        return dbRemote.allAction();
    }

    @RequestMapping("findScheduleByUserId")
    /**
     * @Description: 按找用户id查找计划安排
     * @Param: [id]
     * @return: javax.swing.Action
     * @Author: Izzat
     * @Date: 2019/12/31  23:12
     */
    public ResponseEntity findById(@RequestBody RequestEntity request){
        return dbRemote.findScheduleByUserId(request.getId());
    }

    @RequestMapping("updatePlanByUserAndDate")
    /** 
    * @Description: 更新指定计划 
    * @Param: [request] 
    * @return: izzat.fit.fit_mine.entity.ResponseEntity 
    * @Author: Izzat 
    * @Date: 2020/2/4  14:41
    */ 
    public ResponseEntity updatePlanByUserAndDate(@RequestBody RequestEntity request){
        return dbRemote.updatePlanByUserAndDate(request);
    }

    @RequestMapping("addRecord")
    /** 
    * @Description: 新增一条训练记录 
    * @Param: [record] 
    * @return: izzat.fit.fit_mine.entity.ResponseEntity 
    * @Author: Izzat 
    * @Date: 2020/3/17  10:04
    */ 
    public ResponseEntity addRecord(@RequestBody Record record){
        return dbRemote.addRecord(record);
    }

    @RequestMapping("findHistory")
    /** 
    * @Description: 查找并统计训练记录 
    * @Param: [requset] 
    * @return: izzat.fit.fit_mine.entity.ResponseEntity 
    * @Author: Izzat 
    * @Date: 2020/3/17  11:42
    */ 
    public ResponseEntity findHistory(@RequestBody RequestEntity requset){
        return dbRemote.findHistory(requset);
    }
}
